package com.example.product.grpc;

import io.grpc.Server;
import io.grpc.ServerBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Service;

import java.io.IOException;

@Service
public class GrpcServer {

    public GrpcServer() throws IOException, InterruptedException {
        this.init();
    }

    private void init() throws IOException, InterruptedException {
        System.out.println("启动gRPC服务");
        ServerBuilder serverBuilder = ServerBuilder.forPort(6500);
        serverBuilder.addService(new LoginService());
        Server server = serverBuilder.build();
        //server.start();
        System.out.println("gRPC服务启动完成");

    }
}
